<template>
	<view>
		<winext-tree :data="deptOptions" dataKey="label" arrayKey="id" childrenKey="children" @handleNodeClick="handleNodeClick" class="container">
		</winext-tree>
		<department-person :staffList="staffList" v-show="showList" ref="departmentmanger" />		
	</view>
</template>

<script>
	import {addDept,delDept,treeselect,updateDept} from "@/api/ec/console/org/dept";
	import departmentPerson from './departmentPerson'
	import { listStaffPager } from "@/api/ec/console/org/staff";
	export default {
		components:{departmentPerson},
		data() {
			return {
				showList:false,		   
				deptOptions: [], //部门数据
				itemId:0,
				// 查询参数
				queryParams: {
				    pageNum: 1,
				      pageSize: 10,
				      deptId: null,
				      roleId: null,
				      isCertify: null,
				      params: {
				        findApi: undefined
				      }
				},
				staffList:[], //员工列表 
				itemId:0,//选中的id
			}
		},
		created() {
			// 获取部门 
			this.getTreeselect()
		},
		methods: {
			/** 获取部门 */
			getTreeselect() {
				treeselect().then((response) => {
					this.deptOptions = response.data
				})
			},
			/** 查询员工列表 */ 
			getList(){
        this.$modal.loading();
				this.queryParams.deptId = this.itemId;
				listStaffPager(this.queryParams).then(response => {
				  uni.hideLoading()
				  this.staffList = response.rows;
				});
			},
			handleNodeClick(item){
				this.itemId = item.id
				this.showList = !this.showList
				this.getList()
			},
		}
	}
</script>

<style scoped lang="scss">
	.container {
		background: #fff;
		padding-top: 20rpx;
	}
	::v-deep .winext-tree{width: 100%;}
</style>
